home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17409 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1009 b 

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: STL: Finding an object in a set of Pointers
  5. Date: 15 Apr 1996 19:16:03 GMT
  6. Organization: Borland International
  7. Message-ID: <4ku79j$g1m@druid.borland.com>
  8. References: <4klmjm$kul@access4.digex.net>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4klmjm$kul@access4.digex.net>, car@access4.digex.net says...
  15. >
  16. >
  17. >I am using an STL set to contain *pointers* to objects.
  18. >
  19. >Problem: I want to find out if an object I just created is
  20. >logically contained in the set. 
  21. >
  22. >The find() function will tell me whether the same *address*
  23. >is already in the set, but I need to follow the pointers and
  24. >invoke operator==() on the objects. 
  25. >
  26. >Is there an elegant way I can do this without writing my
  27. >own loop, de-referencing, and comparing?
  28.  
  29. Use find_if, and provide a predicate that handles the dereferencing.
  30.     -- Pete
  31.  
  32.